/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package extension.game.poker;

import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import log.Debug;

/**
 *
 * @author daz
 */
public class PokerCardDealer {

    private int[] cardSetId;
    private List<Integer> cardList;
    private Random random = new Random();

    public PokerCardDealer() {
        cardList = new LinkedList<Integer>();
        cardSetId = new int[52];
        for (int i = 0; i < 52; i++) {
            cardSetId[i] = i;
        }
    }

    public void shuffleCard() {

        cardList.clear();
        for (int i = 0; i < cardSetId.length; i++) {
            int r = random.nextInt(100);
            int temp = cardSetId[i];
            cardSetId[i] = cardSetId[r % 52];
            cardSetId[r % 52] = temp;
        }
//        cardSetId = DataTest.getCardSet13();
        for (int i = 0; i < cardSetId.length; i++) {
            cardList.add(cardSetId[i]);
        }
        Debug.d("card set :" + cardList.toString());
    }

    private void testManyWin() {
        cardSetId = new int[]{8, 29, 47, 27, 26, 20, 49, 33, 12};
    }

    public int nextCard() {
        return cardList.remove(0);
    }
}
